package com.quyunshuo.module.home.data

import com.quyunshuo.module.home.R

data class CoffeeProduct(
    val id: Long,         // 根据商品名生成的唯一ID
    val name: String,     // 商品名称
    val price: Double,    // 商品价格
    val imageUrl: Int  // 商品图片URL
) {
    companion object {
        // 根据商品名生成唯一ID（SHA-256哈希后取前8位转Long）
        fun generateId(name: String): Long {
            val bytes = name.toByteArray()
            val digest = java.security.MessageDigest.getInstance("SHA-256").digest(bytes)
            return digest.take(8).fold(0L) { acc, byte -> (acc shl 8) or (byte.toLong() and 0xFF) }
        }
        val coffeeList = listOf(
            CoffeeProduct(
                id = CoffeeProduct.generateId("哥伦比亚手冲"),
                name = "哥伦比亚手冲",
                price = 32.5,
                imageUrl = R.drawable.setting_icon
            ),
            CoffeeProduct(
                id = CoffeeProduct.generateId("埃塞俄比亚耶加雪菲"),
                name = "埃塞俄比亚耶加雪菲",
                price = 45.0,
                imageUrl = R.drawable.setting_icon
            ),
            CoffeeProduct(
                id = CoffeeProduct.generateId("巴西坚果风味"),
                name = "巴西坚果风味",
                price = 28.8,
                imageUrl = R.drawable.setting_icon
            ),
            CoffeeProduct(
                id = CoffeeProduct.generateId("危地马拉深烘"),
                name = "危地马拉深烘",
                price = 36.0,
                imageUrl = R.drawable.setting_icon
            )
        )
    }
}